package Chuong06;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.*;

public class Bai06 extends JFrame implements MouseMotionListener{

	int x = 0, y = 0;

	@Override
	public void mouseDragged(MouseEvent e) {
		
	}

	@Override
	public void mouseMoved(MouseEvent e) {
		x = e.getX();
		y = e.getY();	
		
		Graphics g = this.getGraphics();
		
		g.setColor(Color.BLUE);
		g.fillOval(x, y, 20, 20);	
		
			try {
				Thread.sleep(10);
			} catch (InterruptedException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

		
		g.setColor(this.getBackground());
		g.fillOval(x, y, 20, 20);
		
		System.out.println(x + "/" + y);
	}

	public Bai06(){
		super("Bài 06 - Chương 06");
		
		addMouseMotionListener(this);
		this.setBackground(Color.WHITE);
	}



	public static void main(String[] args) {
		Bai06 fr = new Bai06();
		fr.setVisible(true);
		fr.setSize(500, 400);
	}
}
